﻿using System;
using System.IO;
using System.Reflection;
using BSpec.Document;

namespace BSpec
{
    public class Console
    {
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                System.Console.WriteLine("Usage \"BSpec.exe <assembly name>\"");
                return;
            }

            string assemblyName = args[0];

            if (File.Exists(Path.GetFullPath(assemblyName)) == false)
            {
                System.Console.WriteLine(String.Format("{0} was not found", assemblyName));
                return;
            }

            Assembly assemblyUnderTest = Assembly.LoadFrom(args[0]);

            System.Console.Write("Generating document...");

            var documentGenerator = new DocumentGenerator(new HtmlRenderer());
            documentGenerator.WriteDocument(assemblyUnderTest);

            System.Console.Write(" finished");
            System.Console.WriteLine();
        }
    }
}
